<template>
  <div>
    <div>
      <el-dialog
        :title="luckysheetName"
        :visible.sync="centerDialogVisible"
        v-if="centerDialogVisible"
        width="50%"
        :fullscreen="fullscreen"
        :lock-scroll="lockScroll"
        :close-on-click-modal="closeOnClickModal"
        :close-on-press-escape="closeOnPressEscape"
      >
        <div style="width: 100%; height: 500px; position: relative">
          <!-- luckysheet 数据编辑组件引用 -->
         <HelloWorld
          ref="luckysheetRef"
          v-on:getLuckySheetData="receive"
          v-bind:sheetParams="sheetParams"
        />
        </div>
        <div slot="footer" class="dialog-footer">
          <el-button @click="handleToClose">取 消</el-button>
          <el-button type="primary" @click="saveSheetData">确 定</el-button>
        </div>
      </el-dialog>
      
    </div>
  </div>
</template>
 
<script>
import HelloWorld from "../components/HelloWorld.vue";
 
export default {
  name: "App",
  components: {
    HelloWorld,
  },
  data() {
    return {
      centerDialogVisible: true,
      closeOnClickModal: false,
      closeOnPressEscape: false,
      fullscreen: false,
      lockScroll: false,
      luckysheetName: "luckysheet数据编辑",
 
      sheetParams: {
        excelHeader: ["姓名", "年龄", "性别"],
        excelData: {
          姓名: ["张三", "赵兰", "李四"],
          年龄: ["18", "17", "20"],
          性别: ["男", "女", "男"],
        },
      },
      luckySheetData: {
        excelHeader: [],
        excelData: {},
      },
    };
  },
  methods: {
    saveSheetData() {
      var _this = this;
      _this.$refs.luckysheetRef.getSheetData(); //调用子组件获取sheet数据
      console.log(JSON.stringify(_this.luckySheetData));
      // document.getElementById("luckysheet-input-box").style.zIndex = "-1";
      // document.getElementsByClassName("luckysheet-cell-input").innerHTML = "";
      // _this.dialogFormVisible = false; //关闭对话框
    },
    //luckySheet数据接收
    receive: function (sheetTitle, commonData) {
      var _this = this;
      _this.luckySheetData.excelHeader = sheetTitle;
      _this.luckySheetData.excelData = commonData;
    },
    handleToClose() {
      this.centerDialogVisible = false;
    }
  },
};
</script>
 
<style>

 
</style>